<template>
  <div>
    <detail-banner
      :sight-name="sightName"
      :banner-img="bannerImg"
      :gallary-imgs="gallaryImgs"
    ></detail-banner>
    <detail-header></detail-header>
    <div class="content-box">
      <detail-list :category-list="categoryList"></detail-list>
    </div>
  </div>
</template>

<script>
import DetailBanner from "./components/Banner";
import DetailHeader from "./components/Header";
import DetailList from "./components/List";
import axios from "axios";

export default {
  name: "CityDetail",
  components: {
    "detail-banner": DetailBanner,
    "detail-header": DetailHeader,
    "detail-list": DetailList
  },
  data() {
    return {
      sightName: "",
      bannerImg: "",
      gallaryImgs: [],
      categoryList: []
    };
  },
  mounted() {
    this.getDetailInfo();
  },
  methods: {
    getDetailInfo() {
      axios
        .get("/api/detail.json", {
          params: {
            id: this.$route.params.id
          }
        })
        .then(this.getDetailInfoSuccess);
    },

    getDetailInfoSuccess(res) {
      if (res.data.ret && res.data.data) {
        const data = res.data.data;
        this.sightName = data.sightName;
        this.bannerImg = data.bannerImg;
        this.gallaryImgs = data.gallaryImgs;
        this.categoryList = data.categoryList;
      }
    }
  }
};
</script>

<style scoped>
.content-box {
  height: 45rem;
}
</style>
